home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kdcopactionproxy.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  4.3 KB  |  113 lines

  1. /* This file is part of the KDE project
  2.    Copyright (C) 1999 Simon Hausmann <hausmann@kde.org>
  3.  
  4.    This library is free software; you can redistribute it and/or
  5.    modify it under the terms of the GNU Library General Public
  6.    License as published by the Free Software Foundation; either
  7.    version 2 of the License, or (at your option) any later version.
  8.  
  9.    This library is distributed in the hope that it will be useful,
  10.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12.    Library General Public License for more details.
  13.  
  14.    You should have received a copy of the GNU Library General Public License
  15.    along with this library; see the file COPYING.LIB.  If not, write to
  16.    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  17.    Boston, MA 02110-1301, USA.
  18. */
  19. #ifndef __kdcopactionproxy_h__
  20. #define __kdcopactionproxy_h__
  21.  
  22. #include <dcopobject.h>
  23. #include <dcopref.h>
  24. #include <kdelibs_export.h>
  25.  
  26. class KActionCollection;
  27. class KAction;
  28.  
  29. /**
  30.  * @short A proxy class publishing a DCOP interface for actions.
  31.  *
  32.  * The KDCOPActionProxy class provides an easy way to publish a collection of KAction objects
  33.  * through DCOP. For the DCOP client the exported actions behave like full-fledged DCOP objects,
  34.  * providing full access to the KAction object functionality in the server.
  35.  *
  36.  * This class can generate DCOP object ids for given action objects, which it automatically
  37.  * processes, as being a DCOPObjectProxy .
  38.  */
  39. class KDEUI_EXPORT KDCOPActionProxy : public DCOPObjectProxy
  40. {
  41. public:
  42.   /**
  43.    * Constructs a dcop action proxy, being able to export the actions of the provided
  44.    * KActionCollection through DCOP, using the parent DCOPObject's object id to
  45.    * generate unique object ids for the actions.
  46.    */
  47.   KDCOPActionProxy( KActionCollection *actionCollection, DCOPObject *parent );
  48.   /**
  49.    * Use this constructor if do not want to provide the exportable actions through a
  50.    * KActionCollection . You have to reimplement the virtual actions() and
  51.    * action() methods if you use this constructor.
  52.    */
  53.   KDCOPActionProxy( DCOPObject *parent );
  54.   /**
  55.    * Destructor.
  56.    */
  57.   ~KDCOPActionProxy();
  58.  
  59.   /**
  60.    * Returns a list of exportable actions. The default implementation returns a list of actions
  61.    * provided by a KActionCollection, if the first constructor has been used.
  62.    */
  63.   virtual QValueList<KAction *> actions() const;
  64.   /**
  65.    * Returns an action object with the given name. The default implementation queries the action object
  66.    * from the KActionCollection, if the first constructor has been used.
  67.    */
  68.   virtual KAction *action( const char *name ) const;
  69.  
  70.   /**
  71.    * Use this method to retrieve a DCOP object id for an action with the given name.
  72.    * This class automatically takes care of processing DCOP object requests for the returned
  73.    * object id.
  74.    *
  75.    * You can construct a global DCOP object referenence using DCOPRef. For example like
  76.    * DCOPRef( kapp->dcopClient()->appId, actionProxy->actionObjectId( actionName ) );
  77.    *
  78.    * The action with the given name has to be available through the #action method.
  79.    */
  80.   virtual QCString actionObjectId( const QCString &name ) const;
  81.  
  82.   /**
  83.    * Returns a map of all exported actions, with the action name as keys and a global DCOP reference
  84.    * as data entries.
  85.    * The appId argument is used to specify the appid component of the DCOP reference. By default the
  86.    * global application id is used ( kapp->dcopClient()->appId() ) .
  87.    */
  88.   virtual QMap<QCString,DCOPRef> actionMap( const QCString &appId = QCString() ) const;
  89.  
  90.   /**
  91.    * Internal reimplementation of DCOPObjectProxy::process .
  92.    */
  93.   virtual bool process( const QCString &obj, const QCString &fun, const QByteArray &data,
  94.                         QCString &replyType, QByteArray &replyData );
  95.  
  96.   /**
  97.    * Called by the #process method and takes care of processing the object request for an
  98.    * action object.
  99.    */
  100.   virtual bool processAction( const QCString &obj, const QCString &fun, const QByteArray &data,
  101.                               QCString &replyType, QByteArray &replyData, KAction *action );
  102. private:
  103.   void init( KActionCollection *collection, DCOPObject *parent );
  104.  
  105. protected:
  106.   virtual void virtual_hook( int id, void* data );
  107. private:
  108.   class KDCOPActionProxyPrivate;
  109.   KDCOPActionProxyPrivate *d;
  110. };
  111.  
  112. #endif
  113.